package com.example.webweb.model;

import com.example.webweb.api.MyCustomConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@Data
@ApiModel(value = "用户实体类") // 类描述
public class User {
    @NotBlank(message = "username not null")
    @ApiModelProperty(value = "用户名")
    private  String username;

    @NotBlank(message = "password not null")
    @MyCustomConstraint(message = "只能以字母或数字组成") // 自定义验证
    @ApiModelProperty(value = "密码")
    private String password;

    @NotNull(message = "sex not null")
    @ApiModelProperty(value = "性别")
    private Integer sex;

    @NotNull(message = "age not null")
    @Min(value = 0,message = "age >= 0")
    @Max(value = 200,message = "age <= 200")  // 最大值
    @ApiModelProperty(value = "年龄")
    private Integer age;

    @NotBlank(message = "email not null") // 非空
    @Email(message = "email nn")    // 邮箱验证
    @ApiModelProperty(value = "邮箱")
    private String email;

    // 创建时间
    private LocalDateTime createTime;
    // 更新日期
    private LocalDate updateTime;
    // 时间
    private LocalTime time;
}
